using ASP;
using HoWave.Common;
using HoWave.Data;
using HoWave.Data.Bll;
using HoWave.Data.Model;
using HoWave.Web.Admin;
using System;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
public class Admin_MBF_VipCardCategoryEdit : Admin, IRequiresSessionState
{
	protected TextBox txtCardCategory;
	protected RequiredFieldValidator rfv1;
	protected RegularExpressionValidator rev1;
	protected TextBox txtCardCategoryName;
	protected RequiredFieldValidator rfv2;
	protected TextBox txtRemark;
	protected Button Add;
	protected Button ButtonReturn;
	private HoWave.Data.Bll.UserCardCategory bllCategory = HoWave.Data.Bll.UserCardCategory.instance;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!this.Page.IsPostBack)
		{
			if (!base.admin.CheckAdminPower(38))
			{
				base.WriteLog("Modidy", Language.GetAdminMsg("Log/Access", "0"), "MBF_VipCardCategoryEdit");
				base.WriteRightErrMsg();
			}
			string text = Fetch.Get("id");
			if (text != "")
			{
				this.ShowInfo(text);
			}
		}
	}
	private void ShowInfo(string id)
	{
		HoWave.Data.Model.UserCardCategory model = this.bllCategory.GetModel(id);
		this.txtCardCategory.Text = model.CardCategory;
		this.txtCardCategoryName.Text = model.CardCategoryName;
		this.txtRemark.Text = model.Remark;
		this.txtCardCategory.ReadOnly = true;
		this.txtCardCategory.Style.Add("Color", "Gray");
	}
	protected void ButtonReturn_Click(object sender, EventArgs e)
	{
		base.Response.Redirect("MBF_VipCardCategoryManage.aspx?MenuID=5&MenuName=卡类管理&FileName=VIP卡类别管理#pos_" + this.txtCardCategory.Text);
	}
	protected void Add_Click(object sender, EventArgs e)
	{
		string text = "";
		if (this.txtCardCategory.Text.Trim() == "")
		{
			text += "请填写类型代号！\\n";
		}
		if (this.txtCardCategoryName.Text.Trim() == "")
		{
			text += "请填写类型名称！\\n";
		}
		if (text != "")
		{
			MessageBox.Show(this, text);
		}
		else
		{
			HoWave.Data.Model.UserCardCategory userCardCategory = new HoWave.Data.Model.UserCardCategory();
			userCardCategory.CardCategory = this.txtCardCategory.Text.Trim();
			userCardCategory.CardCategoryName = this.txtCardCategoryName.Text.Trim();
			userCardCategory.Remark = this.txtRemark.Text;
			if (!this.txtCardCategory.ReadOnly)
			{
				this.bllCategory.Add(userCardCategory);
			}
			else
			{
				this.bllCategory.Update(userCardCategory);
			}
			MessageBox.ShowAndRedirect(this, "保存成功！", "MBF_VipCardCategoryManage.aspx?MenuID=5&MenuName=卡类管理&FileName=VIP卡类别管理#pos_" + userCardCategory.CardCategory);
		}
	}
}
